152A - Marks - CodeForces Solution


implementation *900

Please click on ads to support us..

Python Code:

n,m = map(int,input().split())
l = []
bk = 0
for i in range(n):
	z = input().strip()
	k = "".join(z)
	l.append(k)
	c = ("".join(l))
	k = str(c)
	
v = []
t = 0
i = 0
while i<m:
  c = k[i::m]
  i+=1
  v.append((c))
r = [int(i) for i in v]
f = []
if n == 1:
	print(n)
else:
	c = 0
	for i in v:
	  l = " ".join(i)
	  x = l.split()
	  	  sd = [int(i) for i in x]
	  	  k = set(sd)
	  if len(k)==1:
	  		  	c +=n
	  	bk += 1
	  	break
	  else:
		  cv = list(sd)

		  s = max(cv)
		  index = [i for i in range(len(cv))if cv[i] == s]
		  		  for x in range(len(index)):

		  	f.append(index[x])

		  c+=0
pr = set(f)
if n!=1:
	p = (len(pr))
	if bk==1:
		print(c)
	else:
		print(p+c)












C++ Code:

#include<iostream>
#include<bits/stdc++.h>
#define el endl
#define ll long long
#define du double
#define all(v) v.begin(),v.end()
#define fast ios_base::sync_with_stdio(false),cout.tie(NULL),cin.tie(NULL);
#define Omar_Ahmed_O_H_M codeforce
const int N = 1e9 + 5;
using namespace std;
int main(){
	int n,m,c=0;
	cin>>n>>m;
	string a[n];
	int x[n]={0};
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	
	for(int j=0;j<m;j++)
	{
		int mx=0;
		for(int i=0;i<n;i++)
		{
			
			if(a[i][j]>mx)
			{
				mx=a[i][j];
			}
			
		}
		for(int i=0;i<n;i++)
			{
				if(a[i][j]==mx)
				{
					x[i]=1;
					
				}
			}
	}
	
for(int i=0;i<n;i++)
{
	if(x[i]==1)
	c++;
}
cout<<c;
}


Comments

Submit
0 Comments
More Questions

1516B - AGAGA XOOORRR
1515A - Phoenix and Gold
1515B - Phoenix and Puzzle
155A - I_love_username
49A - Sleuth
1541A - Pretty Permutations
1632C - Strange Test
673A - Bear and Game
276A - Lunch Rush
1205A - Almost Equal
1020B - Badge
1353A - Most Unstable Array
770A - New Password
1646B - Quality vs Quantity
80A - Panoramix's Prediction
1354B - Ternary String
122B - Lucky Substring
266B - Queue at the School
1490A - Dense Array
1650B - DIV + MOD
1549B - Gregor and the Pawn Game
553A - Kyoya and Colored Balls
1364A - XXXXX
1499B - Binary Removals
1569C - Jury Meeting
108A - Palindromic Times
46A - Ball Game
114A - Cifera
776A - A Serial Killer
25B - Phone numbers